
import chatglm_cpp
from PIL import Image
from typing import Optional

class Message:
    def __init__(self, role: str, content: str, tool_calls: int, image: Optional[str] = None):
        self.role = role
        self.content = content
        self.tool_calls = tool_calls
        self.image = image

def from_cpp(cpp_chat_message: chatglm_cpp.ChatMessage) -> Message:
    """
    将 C++ ChatMessage 对象转换为 Python Message 对象。

    :param cpp_chat_message: C++ ChatMessage 对象
    :return: Python Message 对象
    """
    return Message(
        role=cpp_chat_message.role,
        content=cpp_chat_message.content,
        tool_calls=cpp_chat_message.tool_calls,
        image=None  # 如果 image 总是 None，可以考虑在 Message 类中设置默认值 self.image = None
    )